#include "qwtwheelhost.h"


#include "../../libs/qwt/qwt_wheel.h"
#include "../../libs/shared/qhostfactory.h"
#include "../../libs/shared/qpropertyfactory.h"
#include "../../libs/shared/qcommonstruct.h"
#include "../../libs/shared/property/qabstractproperty.h"
#include "../../libs/qwt/qwt_dial_needle.h"

QwtWheelHost::QwtWheelHost(QAbstractHost *parent):
    QWidgetHost(parent)
{
    setProperty("accept_drop",false);
}

void QwtWheelHost::init_property()
{
    QWidgetHost::init_property();

    remove_property("cursor");
    remove_property("enabled");
    remove_property("focusPolicy");
    remove_property("background");
    remove_property("border");
    remove_property("toolTip");
    remove_property("mouseMove");
    remove_property("mousePress");
    remove_property("mouseRelease");
    remove_property("doubleClick");

    QAbstractProperty* pro;

    pro=QPropertyFactory::create_property("Enum");
    if(pro!=NULL)
    {
        pro->set_property("name","orientation");
        pro->set_attribute("show_name",tr("Orientation"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        ComboItems items;
        tagComboItem item;
        item.m_text="Horizontal";
        item.m_value=Qt::Horizontal;
        items.append(item);
        item.m_text="Vertical";
        item.m_value=Qt::Vertical;
        items.append(item);
        pro->set_attribute("items",QVariant::fromValue<ComboItems>(items));
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","value");
        pro->set_attribute("show_name",tr("Value"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro,2);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","minimum");
        pro->set_attribute("show_name",tr("Minimum"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","maximum");
        pro->set_attribute("show_name",tr("Maximum"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","wrapping");
        pro->set_attribute("show_name",tr("Wrapping"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Bool");
    if(pro!=NULL)
    {
        pro->set_property("name","inverted");
        pro->set_attribute("show_name",tr("Inverted"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","totalAngle");
        pro->set_attribute("show_name",tr("Total Angle"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Float");
    if(pro!=NULL)
    {
        pro->set_property("name","viewAngle");
        pro->set_attribute("show_name",tr("View Angle"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","tickCount");
        pro->set_attribute("show_name",tr("Tick Count"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","wheelWidth");
        pro->set_attribute("show_name",tr("Wheel Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","borderWidth");
        pro->set_attribute("show_name",tr("Border Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    pro=QPropertyFactory::create_property("Number");
    if(pro!=NULL)
    {
        pro->set_property("name","wheelBorderWidth");
        pro->set_attribute("show_name",tr("Wheel Border Width"));
        pro->set_attribute("group","Attributes");
        pro->set_attribute(ATTR_CAN_SAME,true);
        insert_property(pro);
    }

    set_property_value("geometry",QRect(0,0,100,30));
}

QString QwtWheelHost::get_show_name()
{
    return tr("QWT Wheel");
}

QString QwtWheelHost::get_show_group()
{
    return tr("QWT Widgets");
}

QString QwtWheelHost::get_show_icon()
{
    return ":/images/icon_compass_alt.png";
}

void QwtWheelHost::create_object()
{
    m_object=new QwtWheel;
    m_object->setObjectName("wheel");
}

qRegisterHost("qwt.wheel",QwtWheelHost,6070)
